HTML Basics: The document head


The head section of a document contains information about the document. This information can be used by search engines, indexing programs and advanced browsers to classify the document better, or to make navigating it easier.

The opening and closing tags for the HEAD element, which encloses the head section, are both optional. If you group all elements which belong in the head together, and do not mix it with the contents of the document (which belongs in the body), this will not cause any problems.

However, a future version of HTML might make using the HEAD element required, to make parsing its contents easier. It is also considered good style to use explicit HEAD and BODY tags to separate the two.


Overview of head elements

What follows is a short overview of all permitted elements in the head (except comments, which are also permitted). For a more detailed overview, see their entry in the Wilbur overview. Note that these elements may occur in random order in the document head, some even more than once.

TITLE

The TITLE tag is probably the most well-known. It is the only required HTML tag in a document, and may be used only once per document. It is used to indicate the title of the current document, which is usually shown in the top of the browser window. It may not contain tags, but may contain entities. Since the title is also used to name an URL in a bookmarks file, or in the results list of a search engine, it should also be descriptive when taken out of context.

BASE

Syntax: <BASE HREF=URL>

Using BASE is only necessary when the URL used to retrieve the document is not the correct one. For example, a document may be mirrored on another site, or a document may be accessible via more than one URL. In such a case, this tag can be used to indicate the correct URL. It must be an absolute URL.

When specified, a browser will use this URL to resolve relative URLs against, rather than the URL it got the document from. Note that if the correct URL is a directory URL, it must be specified with the closing slash.

ISINDEX

When a server has the capability to search a document, it should insert the ISINDEX tag in the document's head. Browsers which support this, can now let the user specify one or more keywords, which are then sent to the server. The server can then perform the search.

Note that the server must have the capability to perform searches. Simply adding <ISINDEX> in the document will not turn your server into a search engine.

LINK

Syntax: <LINK REL|REV=string HREF=URL>

LINK is used to indicate relationships between the current document and the one indicated in the HREF attribute. There are two kinds of relationships. REL indicates that the current document has the indicated relationship to the document specified in the URL. REV indicates a reverse relationship. In other words, the other document has the indicated relationship with this one.

LINK can be used to define the structure of a site. With standard values, such as "Home", "Next", "Prev", "Glossary" or "Copyright" it's very easy to see where this document fits in the site. Unfortunately, very few browsers use this information at this moment. The most popular version is <LINK REV="made" HREF="mailto:foo@bar.com"> which allows a visitor to send comments to the indicated address with just one keystroke. That is, if the browser supports it.

For examples, see the LINK section in the Wilbur overview.

META

Syntax: <META HTTP-EQUIV|NAME=string CONTENT=string>

The META tag is used to provide meta-information about the document, but can also be used to specify headers for the document. By using HTTP-EQUIV, a server should use the name indicated as a header, with the specified CONTENT as its value. If you use NAME instead, only the browser will handle the information.

META statements are most commonly used to advertise the generator of the document, or the name of the author. See the source of this document for an example. The section on META in the Wilbur overview has more examples.

SCRIPT

The SCRIPT element (a container) is used to inline scripts into the document. A script-supporting browser could then execute the script. However, the current specifications only require that a browser hides the contents of this element.

STYLE

Similar to SCRIPT above, STYLE is a container used to embed style sheet information. This information can be used by a style sheet-aware browser to render the document in a better way. Currently, a browser is only required to hide the contents of a STYLE tag. Support for style sheets themselves is optional.

Web Design Group
Reference index ~ HTML Basics index ~ Feedback

Copyright © 1996 Arnoud "Galactus" Engelfriet.